#delimit;
clear all;
version 13.1;
pause on;
program drop _all;
capture log close;
set more off;

/*INSERT FOLDER PATH*/
cd /;


use multi_level_dataset_005_field_vars.dta, clear;
drop if ovrlp_anypos==1;
keep id nbcites_it nbcites_corp_it nbcites_ncorp_it corp_rlvnt_smpl treat age yr srce_pmid srce_year treatX* case_code pubyear shldrs uprght rtrct_reason;
gen subv_of_trth_loose=(shldrs==1|shldrs==2);
gen subv_of_trth_strct=shldrs==2;

/*regs*/

xtqmlp nbcites_it treat i.age i.yr, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main.ster, replace;

xtqmlp nbcites_it treat i.age i.yr if rtrct_reason!=10, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_nonmissing.ster, replace;

xtqmlp nbcites_it treat treatXshky_shldrs treatXabsnt_shldrs i.age i.yr if rtrct_reason!=10, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_shldrs_nonmissing.ster, replace;

xtqmlp nbcites_it treat treatXabsnt_shldrs i.age i.yr if subv_of_trth_loose==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_loose_shldrs.ster, replace;

xtqmlp nbcites_it treat i.age i.yr if (earlst==1 & (shldrs==1|shldrs==2)), fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_shldrs_nonmissing_earlst.ster, replace;


/**/


xtqmlp nbcites_it treat treatXhot3yrprior i.age i.yr if subv_of_trth_loose==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_hotcold_3yrp_shaky&absent.ster, replace;


xtqmlp nbcites_it treat treatXhot3yrprior2550 treatXhot3yrprior5075 treatXhot3yrprior i.age i.yr if subv_of_trth_loose==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_hotcold_3yrp_quartiles_shaky&absent.ster, replace;

xtqmlp nbcites_it treat treatXcrowded i.age i.yr if subv_of_trth_loose==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_crowded_shaky&absent.ster, replace;


xtqmlp nbcites_it treat treatXcrowded2550 treatXcrowded5075 treatXcrowded i.age i.yr if subv_of_trth_loose==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_crowded_quartiles_shaky&absent.ster, replace;

xtqmlp nbcites_it treat treatXqntl_stk_cites6 i.age i.yr if subv_of_trth_strct==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_stk_cites_intr_topquartile_strct.ster, replace;

xtqmlp nbcites_it treat treatXintnt_loose treatXintnt_strct i.age i.yr if subv_of_trth_strct==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_intent_strct.ster, replace;

xtqmlp nbcites_it treat treatXcites i.age i.yr if pubyear>srce_year & subv_of_trth_strct==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_cites_intr_strct.ster, replace;

xtqmlp nbcites_it treat treatXcited i.age i.yr if pubyear<srce_year & subv_of_trth_strct==1, fe i(id) cluster(case_code);
distinct case_code if e(sample);
estadd scalar nbcases=r(ndistinct);
distinct srce_pmid if e(sample);
estadd scalar nbsource=r(ndistinct);
estimates save estimates/poisson_main_cited_intr_strct.ster, replace;



/*tables*/


set emptycells drop;
set matsize 1000;
estimates drop _all;

estimates use  estimates/poisson_main.ster;
eststo;
estimates use  estimates/poisson_main_nonmissing.ster;
eststo;
estimates use  estimates/poisson_main_shldrs_nonmissing.ster;
eststo;
estimates use  estimates/poisson_main_loose_shldrs.ster;
eststo;
estimates use  estimates/poisson_main_shldrs_nonmissing_earlst.ster;
eststo;


esttab *, keep(treat treatXshky_shldrs treatXabsnt_shldrs ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" ) eqlabels(none);
esttab * using tables/table_poisson_main_reasons_intr.rtf, keep(treat treatXshky_shldrs treatXabsnt_shldrs ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" ) eqlabels(none) replace;



set emptycells drop;
set matsize 1000;
estimates drop _all;


estimates use  estimates/poisson_main_stk_cites_intr_topquartile_strct.ster;
eststo;
estimates use  estimates/poisson_main_hotcold_3yrp.ster;
eststo;
estimates use  estimates/poisson_main_crowded.ster;
eststo;
estimates use  estimates/poisson_main_cites_intr_strct.ster;
eststo;
estimates use  estimates/poisson_main_cited_intr_strct.ster;
eststo;
estimates use  estimates/poisson_main_intent_strct.ster;
eststo;



esttab *, keep(treat  treatXqntl_stk_cites6 treatXhot3yrprior treatXcrowded treatXcites treatXcited treatXintnt_loose treatXintnt_strct ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" ) eqlabels(none) coeflabels(
	treat "After Retraction" 
	treatXqntl_stk_cites6 "After Retraction � Highly Cited Source"
	treatXcites "After Retraction � Cites Retracted Piece"
	treatXcited "After Retraction � Cited by Retracted Piece"
	treatXhot3yrprior "After Retraction � �Hot Field�"
	treatXcrowded "After Retraction � �Crowded Field�"
	treatXintnt_loose "After Retraction � Uncertain Intent"
	treatXintnt_strct "After Retraction � Intentional Deception"
	treatXbigfraud "After Retraction � Multiple Fraud Case");
esttab * using tables/table_poisson_main_intr_strct_cites_fields.rtf, keep(treat  treatXqntl_stk_cites6 treatXhot3yrprior treatXcrowded treatXcites treatXcited treatXintnt_loose treatXintnt_strct ) varwidth(25) nonumber noobs nogaps nodep label b(%5.3f) se(%5.3f) star(� 0.10 * 0.05 ** 0.01) compress scalars("nbcases Nb. of Retraction Cases" "nbsource Nb. of Source Articles" "N_g Nb. of Related/Control Articles" "N Nb. of Article-Year Obs." "ll Log Likelihood") sfmt(%10.0fc %10.0fc %10.0fc %10.0fc %10.0fc) mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)") eqlabels(none) coeflabels(
	treat "After Retraction" 
	treatXqntl_stk_cites6 "After Retraction � Highly Cited Source"
	treatXcites "After Retraction � Cites Retracted Piece"
	treatXcited "After Retraction � Cited by Retracted Piece"
	treatXhot3yrprior "After Retraction � �Hot Field�"
	treatXcrowded "After Retraction � �Crowded Field�"
	treatXintnt_loose "After Retraction � Uncertain Intent"
	treatXintnt_strct "After Retraction � Intentional Deception"
	treatXbigfraud "After Retraction � Multiple Fraud Case") replace;

